package com.liao.product.controller;

import com.liao.common.entity.product.SkuAttributeEntity;
import com.liao.common.utils.PageUtils;
import com.liao.product.service.SkuAttributeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Arrays;
import java.util.List;
import java.util.Map;


/**
 * 商品销售属性定义
 *
 * @author liao
 * @email 2858015963@qq.com
 * @date 2025-02-13 13:26:53
 */
@RestController
@RequestMapping("product/skuattribute")
public class SkuAttributeController {
    @Autowired
    private SkuAttributeService skuAttributeService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    public PageUtils<SkuAttributeEntity> list(@RequestParam Map<String, Object> params) {
        return skuAttributeService.queryPage(params);

    }


    /**
     * 列表
     */
    @RequestMapping("/listByProductId/{productId}")
    public List<SkuAttributeEntity> listByProductId(@PathVariable Integer productId) {
//        PageUtils page = skuAttributeService.queryPage(params);
        return skuAttributeService.getListByProductId(productId);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{skuAttrId}")
    public SkuAttributeEntity info(@PathVariable("skuAttrId") Integer skuAttrId) {
        return skuAttributeService.getById(skuAttrId);

    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    public void save(@RequestBody SkuAttributeEntity skuAttribute) {
        skuAttributeService.save(skuAttribute);

    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    public void update(@RequestBody SkuAttributeEntity skuAttribute) {
        skuAttributeService.updateById(skuAttribute);

    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    public void delete(@RequestBody Integer[] skuAttrIds) {
        skuAttributeService.removeByIds(Arrays.asList(skuAttrIds));

    }

}
